package com.linkage.educloud.ah.http;

import com.zhouyou.http.model.HttpParams;
import com.zzhou.common.library.util.StringUtil;
import com.zzhou.common.library.util.Utils;

import java.io.File;
import java.text.SimpleDateFormat;

public class RequestUtil {

    /**
     * 获取欢迎页背景图
     *
     * @param pic_type
     * @return
     */
    public static HttpParams getSplashParams(int pic_type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getSplashPic");
        params.put("pic_type", String.valueOf(pic_type));
        return params;
    }

    /**
     * 自动登录
     *
     * @return
     */
    public static HttpParams autoLogin(int userType, String account, String password, String term) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "login");
        params.put("user_type", String.valueOf(userType));
        params.put("account", account);
        params.put("password", password);
        params.put("term_manufacturer", term);
        return params;
    }

    /**
     * 自动登录
     *
     * @return
     */
    public static HttpParams login(int loginType, int userType, String account, String password, String term) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "loginNew");
        params.put("login_type", String.valueOf(loginType));
        params.put("user_type", String.valueOf(userType));
        params.put("account", account);
        params.put("password", password);
        params.put("term_manufacturer", term);
        return params;
    }

    /**
     * 验证账号
     *
     * @param account
     * @return
     */
    public static HttpParams validateAccount(String account) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "verifyAccount");
        params.put("account", account);
        return params;
    }

    /**
     * 发送登录验证码
     *
     * @param account
     * @return
     */
    public static HttpParams getSmsCode(String account) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "sendSMSCode");
        params.put("account", account);
        params.put("smsType", String.valueOf(3));
        return params;
    }

    /**
     * 获取轮显信息
     *
     * @param userType
     * @return
     */
    public static HttpParams getRollAds(String userType) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getRollAds");
        params.put("radsType", "3".equals(userType) ? "5" : "2");
        return params;
    }

    /**
     * 获取应用信息
     *
     * @param type 接口固定type值
     * @return
     */
    public static HttpParams getMyApps(int type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getMyApps");
        params.put("app_type", "1");
        params.put("type", String.valueOf(type));
        return params;
    }

    /**
     * 获取精彩资讯信息
     *
     * @param pageSize
     * @param pages
     * @return
     */
    public static HttpParams getArticle(int pageSize, int pages) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "gettopicinfolist");
        params.put("token", Utils.getNewsToken());
        params.put("pagesize", String.valueOf(pageSize));
        params.put("pagenum", String.valueOf(pages));
        return params;
    }

    /**
     * 获取消息列表
     *
     * @return
     */
    public static HttpParams getMessageInfo() {
        HttpParams params = new HttpParams();
        params.put("commandtype", "");
        return params;
    }


    /**
     * 获取联系人
     *
     * @return
     */
    public static HttpParams getGroupInfo() {
        HttpParams params = new HttpParams();
        params.put("commandtype", "grouplistnew");
        return params;
    }

    /**
     * 发送邀请请求
     *
     * @return
     */
    public static HttpParams sendInviteInfo(String useId, int userType) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "inviteMsg");
        params.put("userid", useId);
        params.put("usertype", userType + "");
        return params;
    }

    /**
     * 发送邀请请求
     *
     * @return
     */
    public static HttpParams openPhone(long clazzId, int type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "isOpenPhone");
        params.put("clazzid", clazzId + "");
        params.put("type", type + "");
        return params;
    }

    /**
     * 获取班级空间列表
     *
     * @param dynamic_id 0---代表从第一个开始返回  有值---从这个id的下一个开始返回
     * @param clazz_id
     * @param type       0 全部  1 相册  2 公告
     * @return
     */
    public static HttpParams getClassSpaceList(String dynamic_id, int page_size, String clazz_id, int type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getClassSpaceListnew");
        params.put("dynamic_id", dynamic_id);
        params.put("page_size", String.valueOf(page_size));
        params.put("clazz_id", clazz_id);
        params.put("type", String.valueOf(type));
        return params;
    }

    /**
     * 获取班级空间顶部图片
     *
     * @param clazz_id
     * @return
     */
    public static HttpParams getbackground(String clazz_id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getbackground");
        params.put("clazz_id", clazz_id);
        return params;
    }

    /**
     * 班级空间点赞
     *
     * @param id       当前动态的id
     * @param clazz_id 班级id
     * @param type     点赞还是取消赞0--点赞 -1--取消赞
     * @return
     */
    public static HttpParams praisedynamicnew(String id, String clazz_id, int type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "praisedynamicnew");
        params.put("id", id);
        params.put("clazz_id", String.valueOf(clazz_id));
        params.put("type", String.valueOf(type));
        return params;
    }

    /**
     * 班级空间评论，发文字、图片动态
     *
     * @param id       当前动态的id  发动态传空
     * @param clazz_id 班级id
     * @param userid   用户id
     * @param type     发图片--2 发文字--1 评论--4
     * @param usertype 用户类型
     * @param content  评论内容
     *                 uploadimage  发图片 传图片url (发送完图片后拿返回的地址拼接)
     *                 photo_sync  是否发到班级相册  发图片界面看情况传0 其他传-1
     *                 notice_sync  是否发到班级公告  三个发动态界面看情况教师传0  其他-1
     * @return
     */
    public static HttpParams senddynamicmsg(String id, String clazz_id, Long userid, int type, int usertype, String content, String uploadimage, int photo_sync, int notice_sync) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "senddynamicmsg");
        params.put("id", id);
        params.put("clazz_id", clazz_id);
        params.put("userid", String.valueOf(userid));
        params.put("type", String.valueOf(type));
        params.put("role", String.valueOf(usertype));
        params.put("content", content);
        params.put("uploadimage", uploadimage);
        params.put("photo_sync", String.valueOf(photo_sync));
        params.put("notice_sync", String.valueOf(notice_sync));
        return params;
    }

    /**
     * 删除动态/评论
     *
     * @param id   动态id  评论id
     * @param type 1--删动态 2--删评论
     * @return
     */
    public static HttpParams delDynamics(String id, int type) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "delDynamics");
        params.put("id", id);
        params.put("type", String.valueOf(type));
        return params;
    }

    /**
     * 获取发动态的主题
     *
     * @param clazz_id 班级id
     * @param version  版本号
     * @return
     */
    public static HttpParams getTheme(String clazz_id, String version) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getTheme");
        params.put("clazz_id", clazz_id);
        params.put("version", version);
        return params;
    }

    public static HttpParams senddynamicattachment(int type, String clazz_id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "senddynamicattachment");
        params.put("type", String.valueOf(type));
        params.put("clazz_id", clazz_id);
//        params.put("fileupload", file);
        return params;
    }

    /**
     * 获取话题圈group列表
     *
     * @param page 加载第几页
     * @return
     */
    public static HttpParams getTopicGroup(int page) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getTopicGroup");
        params.put("page_size", "10");
        params.put("page", String.valueOf(page));
        return params;
    }

    /**
     * 获取话题圈child tab列表
     *
     * @param id 当前选中的group的id
     * @return
     */
    public static HttpParams getLabels(String id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getLabels");
        params.put("topic_id", id);
        return params;
    }

    /**
     * 获取话题child列表
     *
     * @param topic_id    话题id
     * @param search      搜索关键字
     * @param order_state 排序方式
     * @param label_name  tab标题
     * @param page        页数
     * @return
     */
    public static HttpParams getCards(String topic_id, String search, String order_state, String label_name, int page) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getCards");
        params.put("topic_id", topic_id);
        params.put("search", search);
        params.put("order_state", order_state);
        params.put("label_name", label_name);
        params.put("page_size", "10");
        params.put("page", String.valueOf(page));
        return params;
    }

    /**
     * 获取话题详情
     *
     * @param id 话题id
     * @return
     */
    public static HttpParams getCardDetail(String id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getCardDetail");
        params.put("card_id", id);
        return params;
    }

    /**
     * 获取话题的评论内容  这边没啥人用，就不去做分页了，麻烦，直接一股脑取吧
     *
     * @param id 话题id
     * @return
     */
    public static HttpParams getComments(String id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getComments");
        params.put("card_id", id);
        params.put("page_size", "100");
        params.put("page", "1");
        return params;
    }

    /**
     * 话题详情点赞
     *
     * @param id
     * @param state 1--话题点赞  2--话题下评论点赞
     * @return
     */
    public static HttpParams pushZan(String id, int state) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "pushZan");
        params.put("id", id);
        params.put("state", state + "");
        return params;
    }

    /**
     * 话题详情评论
     *
     * @param id
     * @param text
     * @return
     */
    public static HttpParams pushComment(String id, String text) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "pushComment");
        params.put("card_id", id);
        params.put("content", text);
        return params;
    }

    /**
     * 发布话题帖子
     *
     * @param topic_id 话题组id
     * @param picUrls  图片的url拼接string
     * @param title    标题
     * @param input    内容
     * @return
     */
    public static HttpParams pushCard(String topic_id, String picUrls, String title, String input) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "pushCard");
        params.put("topic_id", topic_id);
        params.put("url", picUrls);
        params.put("title", title);
        params.put("content", input);
        return params;
    }

    /**
     * 获取我回复的帖子
     *
     * @param page
     * @return
     */
    public static HttpParams getMyReplyCards(int page) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getMyReplyCards");
        params.put("page_size", String.valueOf(10));
        params.put("page", String.valueOf(page));
        return params;
    }

    /**
     * 获取我发布的帖子
     *
     * @param page
     * @return
     */
    public static HttpParams getMyCards(int page) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getMyCards");
        params.put("page_size", String.valueOf(10));
        params.put("page", String.valueOf(page));
        return params;
    }

    /**
     * 发表反馈意见
     *
     * @param content
     * @return
     */
    public static HttpParams sendMachineRecord(String content) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "sendMachineRecord");
        params.put("content", content);
        return params;
    }

    /**
     * 获取班级V网消息
     *
     * @return
     */
    public static HttpParams getVClassSurplus(int usertype, String tel) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getVClassSurplus");
        params.put("type", String.valueOf(usertype));
        params.put("mos", String.valueOf(3));
        params.put("tel", tel);
        return params;
    }

    /**
     * 修改密码
     *
     * @param oldPassword 旧密码
     * @param newPassword 新密码
     * @return
     */
    public static HttpParams updatePassword(String oldPassword, String newPassword) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "updatePassword");
        params.put("oldPassword", StringUtil.getMD5Str(oldPassword));
        params.put("newPassword", StringUtil.getMD5Str(newPassword));
        return params;
    }

    /**
     * 获取个人信息
     *
     * @param usertype
     * @return
     */
    public static HttpParams getUserSetting(int usertype) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getUserSetting");
        params.put("usertype", String.valueOf(usertype));
        return params;
    }

    /**
     * 获取教学界面应用类型信息
     *
     * @return
     */
    public static HttpParams getAppClassify() {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getAppClassify");
        return params;
    }

    /**
     * 获取教学界面tab信息
     *
     * @return
     */
    public static HttpParams getResClassify() {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getResClassify");
        return params;
    }

    /**
     * 教学界面 根据年级学科等等信息获取资源
     *
     * @param subjectid
     * @param gradeid
     * @param restype
     * @param pagesize
     * @param page
     * @return
     */
    public static HttpParams getRecommends(int subjectid, int gradeid, int restype, int pagesize, int page) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getRecommends");
        params.put("subjectid", String.valueOf(subjectid));
        params.put("gradeid", String.valueOf(gradeid));
        params.put("restype", String.valueOf(restype));
        params.put("pagesize", String.valueOf(pagesize));
        params.put("page", String.valueOf(page));
        return params;
    }

    /**
     * 获取应用信息
     *
     * @param type
     * @param id
     * @return
     */
    public static HttpParams getApplyList(int type, int id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getApplyList");
        params.put("type", type + "");
        params.put("id", id + "");
        return params;
    }

    /**
     * 获取品牌专区信息
     *
     * @return
     */
    public static HttpParams getBrands() {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getBrands");
        return params;
    }

    /**
     * 搜索资源和应用接口
     *
     * @param skey
     * @param defaultnum
     * @param type
     * @param page
     * @param pagesize
     * @return
     */
    public static HttpParams searchResouces(String skey, int defaultnum, int type, int page, int pagesize) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "searchResouces");
        params.put("skey", skey);
        params.put("defaultnum", String.valueOf(defaultnum));
        params.put("type", String.valueOf(type));
        params.put("page", String.valueOf(page));
        params.put("pagesize", String.valueOf(pagesize));
        return params;
    }

    /**
     * 获取app详情
     *
     * @param id
     * @return
     */
    public static HttpParams getAppDetails(String id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "getAppDetails");
        params.put("id", id);
        return params;
    }

    /**
     * 订购/退订应用
     *
     * @param id
     * @param recommend_code
     * @param type
     * @param service_id
     * @return
     */
    public static HttpParams companyAppGrantNew(int id, String recommend_code, int type, String service_id) {
        HttpParams params = new HttpParams();
        params.put("commandtype", "companyAppGrantNew");
        params.put("id", String.valueOf(id));
        params.put("recommend_code", recommend_code);
        params.put("type", String.valueOf(type));
        params.put("service_id", service_id);
        return params;
    }

    /**
     * 请求记录下载次数 7 下载免费 9 购买  10为家长学堂免费试看
     *
     * @param type
     * @param desid
     * @return
     */
    public static HttpParams statisticsData(int type, int desid) {
        HttpParams params = new HttpParams();
        SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = sDateFormat.format(new java.util.Date());
        params.put("commandtype", "statisticsData");
        params.put("type", String.valueOf(type));
        params.put("desid", String.valueOf(desid));
        params.put("clientTime", date);
        return params;
    }
}
